package com.frain.springcloud.template;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import com.alibaba.fastjson.JSONObject;
import com.frain.springcloud.common.AccessTokenUtil;
import com.frain.springcloud.template.entity.DataEntity;
import com.frain.springcloud.template.entity.TemplateEntity;
import com.frain.springcloud.util.HttpRequest;

public class TemplateTest {

    public static void main(String[] args) throws Exception {

        String token = AccessTokenUtil.getToken();

        String sendUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + token;

        TemplateEntity templateEntity = new TemplateEntity();
        templateEntity.setTemplate_id("TRAuVTNPksQSPMMUQNwTW-qPimxpgNavvZAn4Ujyk_U");
        templateEntity.setTouser("o9HTKv-6SULjnq70TeL562Gfb_y8");
        templateEntity.setUrl("https://www.baidu.com");
        Map<String, DataEntity> data = new HashMap<>();
        data.put("first", new DataEntity("laowang"));
        data.put("beginTime", new DataEntity(new SimpleDateFormat("yyyy-MM-dd  hh:mm:ss").format(new Date())));
        data.put("endTime", new DataEntity(new SimpleDateFormat("yyyy-MM-dd  hh:mm:ss").format(new Date())));
        data.put("remark", new DataEntity("别回复"));
        String remark = "";
        // {"image_id": "NHoNdXRP3CYJWgZoDjFbsQ==", "request_id": "1536633260,fa79552e-d631-4116-baa1-d792ea3edfcf",
        // "time_used": 423, "faces": [{"landmark": {"mouth_upper_lip_left_contour2": {"y": 386, "x": 666},
        // "mouth_upper_lip_top": {"y": 378, "x": 704}, "mouth_upper_lip_left_contour1": {"y": 374, "x": 689},
        // "left_eye_upper_left_quarter": {"y": 239, "x": 610}, "left_eyebrow_lower_middle": {"y": 212, "x": 620},
        // "mouth_upper_lip_left_contour3": {"y": 400, "x": 677}, "right_eye_top": {"y": 241, "x": 777},
        // "left_eye_bottom": {"y": 257, "x": 625}, "right_eyebrow_lower_left_quarter": {"y": 213, "x": 759},
        // "right_eye_pupil": {"y": 249, "x": 775}, "mouth_lower_lip_right_contour1": {"y": 408, "x": 733},
        // "mouth_lower_lip_right_contour3": {"y": 434, "x": 729}, "mouth_lower_lip_right_contour2": {"y": 424, "x":
        // 747}, "contour_chin": {"y": 500, "x": 714}, "contour_left9": {"y": 498, "x": 671},
        // "left_eye_lower_right_quarter": {"y": 256, "x": 641}, "mouth_lower_lip_top": {"y": 407, "x": 705},
        // "right_eyebrow_upper_middle": {"y": 191, "x": 782}, "left_eyebrow_left_corner": {"y": 209, "x": 570},
        // "right_eye_bottom": {"y": 259, "x": 778}, "contour_left7": {"y": 466, "x": 597}, "contour_left6": {"y": 437,
        // "x": 571}, "contour_left5": {"y": 403, "x": 555}, "contour_left4": {"y": 365, "x": 547}, "contour_left3":
        // {"y": 327, "x": 541}, "contour_left2": {"y": 289, "x": 538}, "contour_left1": {"y": 252, "x": 538},
        // "left_eye_lower_left_quarter": {"y": 254, "x": 610}, "contour_right1": {"y": 249, "x": 853},
        // "contour_right3": {"y": 319, "x": 853}, "contour_right2": {"y": 284, "x": 855}, "mouth_left_corner": {"y":
        // 405, "x": 651}, "contour_right4": {"y": 355, "x": 848}, "contour_right7": {"y": 455, "x": 813},
        // "right_eyebrow_left_corner": {"y": 213, "x": 736}, "nose_right": {"y": 331, "x": 751}, "nose_tip": {"y": 316,
        // "x": 705}, "contour_right5": {"y": 391, "x": 842}, "nose_contour_lower_middle": {"y": 350, "x": 706},
        // "left_eyebrow_lower_left_quarter": {"y": 211, "x": 595}, "mouth_lower_lip_left_contour3": {"y": 431, "x":
        // 682}, "right_eye_right_corner": {"y": 249, "x": 805}, "right_eye_lower_right_quarter": {"y": 256, "x": 793},
        // "mouth_upper_lip_right_contour2": {"y": 390, "x": 744}, "right_eyebrow_lower_right_quarter": {"y": 211, "x":
        // 805}, "left_eye_left_corner": {"y": 248, "x": 598}, "mouth_right_corner": {"y": 410, "x": 761},
        // "mouth_upper_lip_right_contour3": {"y": 403, "x": 733}, "right_eye_lower_left_quarter": {"y": 257, "x": 763},
        // "left_eyebrow_right_corner": {"y": 213, "x": 672}, "left_eyebrow_lower_right_quarter": {"y": 214, "x": 646},
        // "right_eye_center": {"y": 250, "x": 778}, "nose_left": {"y": 334, "x": 657}, "mouth_lower_lip_left_contour1":
        // {"y": 406, "x": 677}, "left_eye_upper_right_quarter": {"y": 240, "x": 643}, "right_eyebrow_lower_middle":
        // {"y": 211, "x": 783}, "left_eye_top": {"y": 235, "x": 626}, "left_eye_center": {"y": 248, "x": 626},
        // "contour_left8": {"y": 486, "x": 631}, "contour_right9": {"y": 494, "x": 753}, "right_eye_left_corner": {"y":
        // 252, "x": 750}, "mouth_lower_lip_bottom": {"y": 436, "x": 705}, "left_eyebrow_upper_left_quarter": {"y": 195,
        // "x": 594}, "left_eye_pupil": {"y": 245, "x": 630}, "right_eyebrow_upper_left_quarter": {"y": 196, "x": 756},
        // "contour_right8": {"y": 478, "x": 786}, "right_eyebrow_right_corner": {"y": 210, "x": 826},
        // "right_eye_upper_left_quarter": {"y": 244, "x": 762}, "left_eyebrow_upper_middle": {"y": 192, "x": 622},
        // "right_eyebrow_upper_right_quarter": {"y": 194, "x": 807}, "nose_contour_left1": {"y": 253, "x": 678},
        // "nose_contour_left2": {"y": 309, "x": 668}, "mouth_upper_lip_right_contour1": {"y": 375, "x": 720},
        // "nose_contour_right1": {"y": 251, "x": 729}, "nose_contour_right2": {"y": 306, "x": 740},
        // "mouth_lower_lip_left_contour2": {"y": 420, "x": 664}, "contour_right6": {"y": 425, "x": 831},
        // "nose_contour_right3": {"y": 342, "x": 730}, "nose_contour_left3": {"y": 344, "x": 680},
        // "left_eye_right_corner": {"y": 253, "x": 656}, "left_eyebrow_upper_right_quarter": {"y": 197, "x": 650},
        // "right_eye_upper_right_quarter": {"y": 243, "x": 792}, "mouth_upper_lip_bottom": {"y": 400, "x": 705}},
        // "attributes": {"emotion": {"sadness": 0.84, "neutral": 0.91, "disgust": 9.271, "anger": 15.951, "surprise":
        // 70.549, "fear": 1.727, "happiness": 0.752}, "beauty": {"female_score": 46.826, "male_score": 48.805},
        // "gender": {"value": "Male"}, "age": {"value": 23}, "mouthstatus": {"close": 30.499,
        // "surgical_mask_or_respirator": 0.033, "open": 69.162, "other_occlusion": 0.305}, "glass": {"value":
        // "Normal"}, "skinstatus": {"dark_circle": 0.922, "stain": 9.755, "acne": 12.697, "health": 9.504}, "headpose":
        // {"yaw_angle": 2.2623267, "pitch_angle": 0.19114113, "roll_angle": 1.7117559}, "blur": {"blurness":
        // {"threshold": 50.0, "value": 0.366}, "motionblur": {"threshold": 50.0, "value": 0.366}, "gaussianblur":
        // {"threshold": 50.0, "value": 0.366}}, "smile": {"threshold": 50.0, "value": 0.006}, "eyestatus":
        // {"left_eye_status": {"normal_glass_eye_open": 99.153, "no_glass_eye_close": 0.0, "occlusion": 0.001,
        // "no_glass_eye_open": 0.81, "normal_glass_eye_close": 0.002, "dark_glasses": 0.033}, "right_eye_status":
        // {"normal_glass_eye_open": 99.787, "no_glass_eye_close": 0.0, "occlusion": 0.0, "no_glass_eye_open": 0.157,
        // "normal_glass_eye_close": 0.054, "dark_glasses": 0.001}}, "facequality": {"threshold": 70.1, "value": 93.76},
        // "ethnicity": {"value": "ASIAN"}, "eyegaze": {"right_eye_gaze": {"position_x_coordinate": 0.497,
        // "vector_z_component": 0.968, "vector_x_component": 0.252, "vector_y_component": 0.006,
        // "position_y_coordinate": 0.407}, "left_eye_gaze": {"position_x_coordinate": 0.512, "vector_z_component":
        // 0.978, "vector_x_component": 0.176, "vector_y_component": 0.109, "position_y_coordinate": 0.44}}},
        // "face_rectangle": {"width": 317, "top": 185, "left": 535, "height": 317}, "face_token":
        // "e9fa04b96412a3abfe1d305dc2269b74"}]}

        templateEntity.setData(data);
        String string = HttpRequest.sendPost(sendUrl, JSONObject.toJSONString(templateEntity), null);
        System.out.println(string);

    }

}
